﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FOModels.AppConfig;
using System.Data;
namespace DataAccess.AppConfig
{
    public class AppConfigDAL
    {
        private SQLDataAccess db;
        public AppConfigDAL()
        {
            db = new SQLDataAccess();
        }
        public DataTable getAppConfig(int AppConfigID, int langid)
        {
            return db.exeSelect("Select * from AppConfig a join AppConfigLang al on a.AppConfigID = al.AppConfigID where LangID = " + langid + " and a.AppConfigID = " + AppConfigID + "");
        }

        public int UpdateAppConfig(AppConfigModels models)
        {
            return db.exeUpdate("update AppConfig set MailServer=N'" + models.MailServer + "',MailUser =N'" + models.MailUser + "',MailPassword=N'" + models.MailPassword + "',MailPort=N'" + models.MailPort + "', CallCenter = N'" + models.CallCenter + "' where AppConfigID = " + models.AppConfigID + "");
        }
        public int UpdateAppConfigLang(AppConfigModels models, int langid)
        {
            return db.exeUpdate("update AppConfigLang set Term=N'" + models.Term + "' , SiteTitle = N'" + models.SiteTitle + "',IntroSite=N'" + models.IntroSite + "',Contact = N'" + models.Contact + "' ,AboutUs = N'" + models.AboutUs + "' where AppConfigID = " + models.AppConfigID + " and LangID = " + langid + "");
        }
    }
}
